package org.mall.modules.pojo.product.vo.commodity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.mall.common.util.jsonschema.Long2StringSerializer;
import org.mall.common.util.jsonschema.String2LongDeserialize;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/***
 *@author yinxucun
 *@date 2020-01-06 12:02 
 */
@Data
public class ProductSpuVO {
    private static final long serialVersionUID = 1L;

    /**状态(1上架，2下架)*/
    @Excel(name = "状态(1上架，2下架)", width = 15)
    private Boolean visible;
    /**品牌ID*/
    private String brandId;
    /**副标题*/
    private String caption;
    /**一级类目*/

    private String categoryId;

    @Excel(name = "三级类目名称", width = 15)
    private String categoryName;
    /**条目（方便商户管理商品）*/
    private String entryId;
    /**条目名称（方便商户管理商品）*/
    private String entryName;
    /**分类编号*/
    private Integer cid;
    /**创建时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**默认SKU*/
    @JsonDeserialize(using = String2LongDeserialize.class)
    @JsonSerialize(using = Long2StringSerializer.class)
    private Long defaultItemId;
    /**是否删除*/
    @Excel(name = "是否删除（0;未删除，1：删除）", width = 15)
    private Boolean deleted;
    /**描述*/

    private String description;
    /**SPU 编号*/
    @JsonDeserialize(using = String2LongDeserialize.class)
    @JsonSerialize(using = Long2StringSerializer.class)
    private Long id;

    /**是否启用规格*/
    private String isEnableSpec;
    /**是否上架*/
    private String isMarketable;
    /**SPU 名字*/
    private String name;
    /**商品主图地址
     *
     * 数组，以逗号分隔
     *
     * 建议尺寸：800*800像素，你可以拖拽图片调整顺序，最多上传15张1*/
    private String picUrls;
    /**原价*/
    private Integer price;

    /**现价*/
    private Integer presentPrice;

    /**库存数量*/
    private Integer quantity;
    /**卖点*/
    private String sellPoint;
    /**商家ID*/
    private String sellerId;
    /**店铺_id*/
    private String shopId;
    /**排序字段*/
    private Integer sort;
    /**模板类型ID（待用）*/
    private String templateTypeId;
    /**审核（0：待审核。1审核通过）*/
    private String toExamine;
    /**最后更新时间*/
    private Date updateTime;
    private List<CommoditySkuVO> productSkuList;

    private String ids;

    private Integer sales;
    private String shopName;

    public List<String> getPicUrls() {
        if (picUrls==null){
            return Collections.emptyList();
        }
        return Arrays.asList(picUrls.split(","));
    }
}
